package cn.kgc.springboot.service;

import cn.kgc.springboot.entity.User;
import cn.kgc.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: mosin
 * @version: v1.0  2022/7/20
 */
@Service
public class UserServiceImpl implements  UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getAll() {
        List<User> users = userMapper.selectAll();
        return users;
    }

    @Override
    public User getOne(Integer id) {

        return  userMapper.selectOne(id);
    }

    @Override
    public User addOne(User user) {
        Integer line =  userMapper.addUser(user);
        return user;
    }

    @Override
    public Boolean deleteOne(Integer id) {
        Integer line =  userMapper.deleteOne(id);
        return line>0;
    }
}
